package com.exam.controller;

import com.exam.pojo.Admin;
import com.exam.pojo.LoginUser;
import com.exam.pojo.Student;
import com.exam.pojo.Teacher;
import com.exam.service.LoginService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;


@RestController
public class LoginController {
    @Resource
    private LoginService loginService;

    @PostMapping("/login/student")
    public Student loginStu(@RequestBody LoginUser loginUser){
        Student loginStu = loginService.loginStu(loginUser.getUsername(), loginUser.getPassword(), loginUser.getRole());
        return loginStu;
    }
    @PostMapping("/login/teacher")
    public Teacher loginTea(@RequestBody LoginUser loginUser){
        Teacher loginTea = loginService.loginTea(loginUser.getUsername(), loginUser.getPassword(), loginUser.getRole());
        return loginTea;
    }
    @PostMapping("/login/admin")
    public Admin loginAdmin(@RequestBody LoginUser loginUser){
        Admin loginAdmin = loginService.loginAdmin(loginUser.getUsername(), loginUser.getPassword(), loginUser.getRole());
        return loginAdmin;
    }
    @PutMapping("/login/edit")
    public Boolean editPwd(@RequestBody LoginUser loginUser){
        return loginService.updatePwd(loginUser);
    }
}
